I want to export a single Item (SPListItem) or a file (Any object that inharits ISecurableObject) and export these objects with their security settings (the permissions on the item), but event though I set the parameter for security, the export cab contains to data on Permissions (although all the users and modifiers appeare), and so does the imported item.
This is what I write:
SPSite site = new SPSite("http://shp1/sites/MorSource/FeelingGood2");
SPWeb web = site.OpenWeb();
SPExport export = new SPExport();
export.Settings.OverwriteExistingDataFile = true;
export.Settings.CommandLineVerbose = true;
export.Settings.AutoGenerateDataFileName = true;
export.Settings.ExportMethod = SPExportMethodType.ExportAll;
export.Settings.SiteUrl = "http://shp1/sites/MorSource/FeelingGood2";
export.Settings.BaseFileName = "C:\\Exports\\export.cab";
export.Settings.IncludeSecurity = SPIncludeSecurity.All;
export.Settings.IncludeVersions = SPIncludeVersions.All;
export.Settings.ExportObjects.Add(new SPExportObject(
web.GetFile("http://shp1/sites/MorSource/FeelingGood2/Wiki/Mor.aspx").UniqueId,
SPDeploymentObjectType.ListItem,
web.GetList("http://shp1/sites/MorSource/FeelingGood2/Wiki").ID, SPIncludeDescendants.All));
export.Run();
When looking at the permissions on an item, you don't see it under the url of the file\item but under the url of the web, and I suspect that means that the export process does not consider the security as hierarchicaly under the item.
Please confirm my opinions or contradict me,
Thank you,
Mor.
Hi,
I'm not clear from your post what's the problem? I have used the SPExport/SPImport for the same reason and it's working fine. Would you please explain your problem a bit elaborately?
Thanks
Sohel Rana
Hi,
Are data of the item being imported with the user information? Once I had faced with a problem that only the user information was being imported without any data and the exported file was small in size (around 3KB whereas it should be 3MB). If you are only getting the user information without any site data (say list items) then the problem may be with that you are not running your codeusing administrator's credential. Run the code with the windows user who is the Farm level administrator. As I know the Farm level administrator is the user who has installed the SharePoint in the server.
Thanks
Sohel Rana
export.Settings.ExportObjects.Add(new SPExportObject(
web.GetFile("http://shp1/sites/MorSource/FeelingGood2/Wiki/Mor.aspx").UniqueId,
SPDeploymentObjectType.ListItem,
web.GetList("http://shp1/sites/MorSource/FeelingGood2/Wiki").ID, SPIncludeDescendants.All));
In this example the file and the metadata are being imported ok, but the security on that file is not imported.
Can you show your import code?
Are you setting IncludeSecurity=true on the SPImportSettings object?
import.Settings.SiteUrl = site.Url;
import.Settings.BaseFileName = folder + "\\" + fileName;
import.Settings.UpdateVersions = SPUpdateVersions.Append);
import.Settings.IgnoreWebParts = false;
import.Settings.UserInfoDateTime = SPImportUserInfoDateTimeOption.ImportAll;
import.Settings.WebUrl = web.Url;
import.Settings.CommandLineVerbose = true;
import.Settings.LogFilePath = logPath;
import.Run();
But again, I looked in the export file (opened it as a cab) and manually scanned the xml files inside, and there were no security data available.
Thank you.
Any chance you've managed to export its security data?